#include "amlight.h"
#include "util/ammath.h"

AMLight::AMLight() {
    m_Light = GL_LIGHT0;
    init();
}

AMLight::AMLight(GLenum light) : m_Light(light) {
    init();
}

AMLight::AMLight(const AMLight & o) {
    m_Light = o.m_Light;
    memcpy(m_LightAmbient, o.m_LightAmbient, sizeof(float) * 4);
    memcpy(m_LightSpecular, o.m_LightSpecular, sizeof(float) * 4);
    memcpy(m_LightDiffuse, o.m_LightDiffuse, sizeof(float) * 4);
    memcpy(m_LightPosition, o.m_LightPosition, sizeof(float) * 4);
}

void AMLight::init() {
    memcpy(m_LightAmbient, AMMath::ZERO_4VECT, sizeof(float) * 4);
    memcpy(m_LightSpecular, AMMath::ZERO_4VECT, sizeof(float) * 4);
    memcpy(m_LightDiffuse, AMMath::ZERO_4VECT, sizeof(float) * 4);
    memcpy(m_LightPosition, AMMath::ZERO_4VECT, sizeof(float) * 4);
}

void AMLight::render() const {
    glLightfv(m_Light, GL_SPECULAR, m_LightSpecular);
    glLightfv(m_Light, GL_AMBIENT, m_LightAmbient);
    glLightfv(m_Light, GL_DIFFUSE, m_LightDiffuse);
    glLightfv(m_Light, GL_POSITION, m_LightPosition);
}
